package com.teach.service.impl;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.teach.dto.ProductAndShopSlide;
import com.teach.dto.ShopOrderItemSearch;
import com.teach.entity.Product;
import com.teach.entity.ProductClass;
import com.teach.entity.ShopOrder;
import com.teach.entity.ShopOrderItem;
import com.teach.entity.ShopSlide;
import com.teach.mapper.ProductClassMapper;
import com.teach.service.shop.ShopIndexService;

@Service
public class ShopIndexServiceImpl implements ShopIndexService{
	
	@Autowired
	private ProductClassMapper product;
	
	@Cacheable(value = "ShopIndexService",key = "'findAll'")
	@Override
	public List<ProductClass> findAll() {
		return product.findAll();
	}

	@Override
	public List<ShopSlide> slideFindAll() {
		return product.slideFindAll();
	}

	@Override
	public List<ProductAndShopSlide> pandsFindAll() {
		List<ProductClass> list = product.findAll();
		List<ProductAndShopSlide> andShopSlides = new ArrayList<ProductAndShopSlide>();
		for (ProductClass productClass : list) {
			ProductAndShopSlide productAndShopSlide = new ProductAndShopSlide();
			Integer classId = productClass.getProductClassId();
			String productClassName = productClass.getProductClassName();
			List<Product> pandsFindAll = product.pandsFindAll(classId);
			productAndShopSlide.setProductClassId(classId);
			productAndShopSlide.setProductClassName(productClassName);
			productAndShopSlide.setSearchs(pandsFindAll);
			andShopSlides.add(productAndShopSlide);
		}
		return andShopSlides;
	}

	@Override
	public List<ShopOrderItem> orderFindAll() {
		return product.orderFindAll();
	}

	

}
